'''
Created on 17.08.2011

@author: osman
'''

from opf.constants import UNIT
from pydoc import cram

def freezeResult(result):
    '''
    Makes a frozensets of pairs from a dict
    '''
    return frozenset(result.items())

def freezeResults(results):
    '''
    Makes a set of frozensets of pairs from a sequence of dict's
    '''
    return set(frozenset(x.items()) for x in results)

def fmtQ(quadruple, smaxlen = 100):
    quadruple = tuple(isinstance(x, str) and '"%s"' % cram(x.strip(), smaxlen) or x
                      for x in quadruple)
    return " ".join(str(x) for x in quadruple[1:] if x is not UNIT)